Intersection snd other set operations on node-sets

By  Dimitre Novatchev
 
Language  XSLT
Category xml, designpatterns
Posted 29  Jan  2001
Updated 04  Feb  2001
 
Summary
This snippet describes how to use the "Kaysian method" to express the intersection of two node-sets in pure XPath.
 
The only set operation provided in XSLT is the Union -- and it can be specified using the XPath and XSLT union operator "|".
 
Until recently it was believed that in order to implement other types of set operations (e.g. intersection) one could only resort on using extension functions -- and different XSLT processors provided such extensions (e.g. saxon:intersection).
 
As it turned out in June 2000, it is possible to express the intersection of two node-sets in pure XPath. This technique was discovered by Michael Kay and is known as the Kaysian method.
 
XSL Code:
 
XML Code: